package com.only4play.practice.pay.reconcile.core.model.payconfig;

import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.only4play.practice.common.enums.pay.OutPayChannelType;

import java.io.IOException;

/**
 * @author mengdy
 */
public class PayConfigFactory {

    private static final Gson GSON = new Gson();


    public static PayConfig parseConfig(String channelPayConfig, OutPayChannelType channelType) throws IOException {
        if (channelType == null) {
            throw new IllegalArgumentException("支付渠道不能为空!");
        }
        switch (channelType) {
            case WECHAT:
                return GSON.fromJson(channelPayConfig, WechatPayConfig.class);
            case ALIPAY:
                return GSON.fromJson(channelPayConfig, AliPayConfig.class);
            // 添加更多渠道类型
            default:
                throw new RuntimeException("暂未支持当前渠道类型: " + channelType);
        }
    }
}
